package com.ruoyi.exam.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamMakeupCourse;
import com.ruoyi.exam.service.IExamMakeupCourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补缓考课程管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/exam/makeupCourse")
public class ExamMakeupCourseController extends BaseController
{
    @Autowired
    private IExamMakeupCourseService examMakeupCourseService;

    /**
     * 查询补缓考课程管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamMakeupCourse examMakeupCourse)
    {
        startPage();
        List<ExamMakeupCourse> list = examMakeupCourseService.selectExamMakeupCourseList(examMakeupCourse);
        return getDataTable(list);
    }

    /**
     * 导出补缓考课程管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupCourse:export')")
    @Log(title = "补缓考课程管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamMakeupCourse examMakeupCourse)
    {
        List<ExamMakeupCourse> list = examMakeupCourseService.selectExamMakeupCourseList(examMakeupCourse);
        ExcelUtil<ExamMakeupCourse> util = new ExcelUtil<ExamMakeupCourse>(ExamMakeupCourse.class);
        util.exportExcel(response, list, "补缓考课程管理数据");
    }

    /**
     * 获取补缓考课程管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupCourse:query')")
    @GetMapping(value = "/{makeupId}")
    public AjaxResult getInfo(@PathVariable("makeupId") Long makeupId)
    {
        return success(examMakeupCourseService.selectExamMakeupCourseByMakeupId(makeupId));
    }

    /**
     * 新增补缓考课程管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupCourse:add')")
    @Log(title = "补缓考课程管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamMakeupCourse examMakeupCourse)
    {
        return toAjax(examMakeupCourseService.insertExamMakeupCourse(examMakeupCourse));
    }

    /**
     * 修改补缓考课程管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupCourse:edit')")
    @Log(title = "补缓考课程管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamMakeupCourse examMakeupCourse)
    {
        return toAjax(examMakeupCourseService.updateExamMakeupCourse(examMakeupCourse));
    }

    /**
     * 删除补缓考课程管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupCourse:remove')")
    @Log(title = "补缓考课程管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{makeupIds}")
    public AjaxResult remove(@PathVariable Long[] makeupIds)
    {
        return toAjax(examMakeupCourseService.deleteExamMakeupCourseByMakeupIds(makeupIds));
    }
}
